<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="设备归属租户" prop="tenantId">
        <el-input
          v-model="queryParams.tenantId"
          placeholder="请输入设备归属租户"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="厂家编号" prop="supplierId">
        <el-input
          v-model="queryParams.supplierId"
          placeholder="请输入厂家编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="locationNb">
        <el-input
          v-model="queryParams.locationNb"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备编号" prop="terminalId">
        <el-input
          v-model="queryParams.terminalId"
          placeholder="请输入设备编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="功能ID号" prop="funId">
        <el-input
          v-model="queryParams.funId"
          placeholder="请输入功能ID号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="反转ID号" prop="ytId">
        <el-input
          v-model="queryParams.ytId"
          placeholder="请输入反转ID号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="初始用电量" prop="firstVal">
        <el-input
          v-model="queryParams.firstVal"
          placeholder="请输入初始用电量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最后用电量" prop="lastVal">
        <el-input
          v-model="queryParams.lastVal"
          placeholder="请输入最后用电量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最小值" prop="minVal">
        <el-input
          v-model="queryParams.minVal"
          placeholder="请输入最小值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最大值" prop="maxVal">
        <el-input
          v-model="queryParams.maxVal"
          placeholder="请输入最大值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="初始时间" prop="firstTime">
        <el-date-picker clearable
          v-model="queryParams.firstTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择初始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="最后更新时间" prop="lastTime">
        <el-date-picker clearable
          v-model="queryParams.lastTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择最后更新时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="最小值发生时间" prop="minTime">
        <el-date-picker clearable
          v-model="queryParams.minTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择最小值发生时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="最大值发生时间" prop="maxTime">
        <el-date-picker clearable
          v-model="queryParams.maxTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择最大值发生时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="当前采集值" prop="dataValue">
        <el-input
          v-model="queryParams.dataValue"
          placeholder="请输入当前采集值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="倍率" prop="multiply">
        <el-input
          v-model="queryParams.multiply"
          placeholder="请输入倍率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手动输入值" prop="inVal">
        <el-input
          v-model="queryParams.inVal"
          placeholder="请输入手动输入值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开始尖" prop="firstVal1st">
        <el-input
          v-model="queryParams.firstVal1st"
          placeholder="请输入开始尖"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开始峰" prop="firstVal2nd">
        <el-input
          v-model="queryParams.firstVal2nd"
          placeholder="请输入开始峰"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开始平" prop="firstVal3rd">
        <el-input
          v-model="queryParams.firstVal3rd"
          placeholder="请输入开始平"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开始谷" prop="firstVal4th">
        <el-input
          v-model="queryParams.firstVal4th"
          placeholder="请输入开始谷"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最后尖" prop="lastVal1st">
        <el-input
          v-model="queryParams.lastVal1st"
          placeholder="请输入最后尖"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最后峰" prop="lastVal2nd">
        <el-input
          v-model="queryParams.lastVal2nd"
          placeholder="请输入最后峰"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最后平" prop="lastVal3rd">
        <el-input
          v-model="queryParams.lastVal3rd"
          placeholder="请输入最后平"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最后谷" prop="lastVal4th">
        <el-input
          v-model="queryParams.lastVal4th"
          placeholder="请输入最后谷"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="净累积量" prop="cumulativeFlow">
        <el-input
          v-model="queryParams.cumulativeFlow"
          placeholder="请输入净累积量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="平均电池电压" prop="terminalVolAvg">
        <el-input
          v-model="queryParams.terminalVolAvg"
          placeholder="请输入平均电池电压"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="起始抄表读数" prop="startReading">
        <el-input
          v-model="queryParams.startReading"
          placeholder="请输入起始抄表读数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="起始抄表时间" prop="startReadingTime">
        <el-date-picker clearable
          v-model="queryParams.startReadingTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择起始抄表时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="终止抄表读数" prop="endReading">
        <el-input
          v-model="queryParams.endReading"
          placeholder="请输入终止抄表读数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="终止抄表时间" prop="endReadingTime">
        <el-date-picker clearable
          v-model="queryParams.endReadingTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择终止抄表时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="用户平均用水量" prop="userAvg">
        <el-input
          v-model="queryParams.userAvg"
          placeholder="请输入用户平均用水量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="环比上一周期" prop="hb">
        <el-input
          v-model="queryParams.hb"
          placeholder="请输入环比上一周期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="冻结时间" prop="freezeTime">
        <el-input
          v-model="queryParams.freezeTime"
          placeholder="请输入冻结时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="抄回状态(1：当天和前天都抄回数据,2：当天有数据抄回，前一天未抄回数据,3：当天未抄回数据。当天表示需要生成日用量的那天。)" prop="copyRate">
        <el-input
          v-model="queryParams.copyRate"
          placeholder="请输入抄回状态(1：当天和前天都抄回数据,2：当天有数据抄回，前一天未抄回数据,3：当天未抄回数据。当天表示需要生成日用量的那天。)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['basedata:electricityTerminalsFreezeXb:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['basedata:electricityTerminalsFreezeXb:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['basedata:electricityTerminalsFreezeXb:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['basedata:electricityTerminalsFreezeXb:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="electricityTerminalsFreezeXbList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="平台表单自增主键" align="center" prop="id" />
      <el-table-column label="设备归属租户" align="center" prop="tenantId" />
      <el-table-column label="厂家编号" align="center" prop="supplierId" />
      <el-table-column label="${comment}" align="center" prop="locationNb" />
      <el-table-column label="设备编号" align="center" prop="terminalId" />
      <el-table-column label="功能ID号" align="center" prop="funId" />
      <el-table-column label="反转ID号" align="center" prop="ytId" />
      <el-table-column label="初始用电量" align="center" prop="firstVal" />
      <el-table-column label="最后用电量" align="center" prop="lastVal" />
      <el-table-column label="最小值" align="center" prop="minVal" />
      <el-table-column label="最大值" align="center" prop="maxVal" />
      <el-table-column label="初始时间" align="center" prop="firstTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.firstTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最后更新时间" align="center" prop="lastTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最小值发生时间" align="center" prop="minTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.minTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最大值发生时间" align="center" prop="maxTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.maxTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="当前采集值" align="center" prop="dataValue" />
      <el-table-column label="倍率" align="center" prop="multiply" />
      <el-table-column label="手动输入值" align="center" prop="inVal" />
      <el-table-column label="开始尖" align="center" prop="firstVal1st" />
      <el-table-column label="开始峰" align="center" prop="firstVal2nd" />
      <el-table-column label="开始平" align="center" prop="firstVal3rd" />
      <el-table-column label="开始谷" align="center" prop="firstVal4th" />
      <el-table-column label="最后尖" align="center" prop="lastVal1st" />
      <el-table-column label="最后峰" align="center" prop="lastVal2nd" />
      <el-table-column label="最后平" align="center" prop="lastVal3rd" />
      <el-table-column label="最后谷" align="center" prop="lastVal4th" />
      <el-table-column label="净累积量" align="center" prop="cumulativeFlow" />
      <el-table-column label="平均电池电压" align="center" prop="terminalVolAvg" />
      <el-table-column label="起始抄表读数" align="center" prop="startReading" />
      <el-table-column label="起始抄表时间" align="center" prop="startReadingTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startReadingTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="终止抄表读数" align="center" prop="endReading" />
      <el-table-column label="终止抄表时间" align="center" prop="endReadingTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endReadingTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="用户平均用水量" align="center" prop="userAvg" />
      <el-table-column label="环比上一周期" align="center" prop="hb" />
      <el-table-column label="用水状态，报警策略设置的参数计算" align="center" prop="paramType" />
      <el-table-column label="冻结类型，时：hour 日：day，月：month" align="center" prop="frozenType" />
      <el-table-column label="冻结时间" align="center" prop="freezeTime" />
      <el-table-column label="抄回状态(1：当天和前天都抄回数据,2：当天有数据抄回，前一天未抄回数据,3：当天未抄回数据。当天表示需要生成日用量的那天。)" align="center" prop="copyRate" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['basedata:electricityTerminalsFreezeXb:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['basedata:electricityTerminalsFreezeXb:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改电冻结数据（设备维度）对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="设备归属租户" prop="tenantId">
          <el-input v-model="form.tenantId" placeholder="请输入设备归属租户" />
        </el-form-item>
        <el-form-item label="厂家编号" prop="supplierId">
          <el-input v-model="form.supplierId" placeholder="请输入厂家编号" />
        </el-form-item>
        <el-form-item label="${comment}" prop="locationNb">
          <el-input v-model="form.locationNb" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="设备编号" prop="terminalId">
          <el-input v-model="form.terminalId" placeholder="请输入设备编号" />
        </el-form-item>
        <el-form-item label="功能ID号" prop="funId">
          <el-input v-model="form.funId" placeholder="请输入功能ID号" />
        </el-form-item>
        <el-form-item label="反转ID号" prop="ytId">
          <el-input v-model="form.ytId" placeholder="请输入反转ID号" />
        </el-form-item>
        <el-form-item label="初始用电量" prop="firstVal">
          <el-input v-model="form.firstVal" placeholder="请输入初始用电量" />
        </el-form-item>
        <el-form-item label="最后用电量" prop="lastVal">
          <el-input v-model="form.lastVal" placeholder="请输入最后用电量" />
        </el-form-item>
        <el-form-item label="最小值" prop="minVal">
          <el-input v-model="form.minVal" placeholder="请输入最小值" />
        </el-form-item>
        <el-form-item label="最大值" prop="maxVal">
          <el-input v-model="form.maxVal" placeholder="请输入最大值" />
        </el-form-item>
        <el-form-item label="初始时间" prop="firstTime">
          <el-date-picker clearable
            v-model="form.firstTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择初始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="最后更新时间" prop="lastTime">
          <el-date-picker clearable
            v-model="form.lastTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择最后更新时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="最小值发生时间" prop="minTime">
          <el-date-picker clearable
            v-model="form.minTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择最小值发生时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="最大值发生时间" prop="maxTime">
          <el-date-picker clearable
            v-model="form.maxTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择最大值发生时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="当前采集值" prop="dataValue">
          <el-input v-model="form.dataValue" placeholder="请输入当前采集值" />
        </el-form-item>
        <el-form-item label="倍率" prop="multiply">
          <el-input v-model="form.multiply" placeholder="请输入倍率" />
        </el-form-item>
        <el-form-item label="手动输入值" prop="inVal">
          <el-input v-model="form.inVal" placeholder="请输入手动输入值" />
        </el-form-item>
        <el-form-item label="开始尖" prop="firstVal1st">
          <el-input v-model="form.firstVal1st" placeholder="请输入开始尖" />
        </el-form-item>
        <el-form-item label="开始峰" prop="firstVal2nd">
          <el-input v-model="form.firstVal2nd" placeholder="请输入开始峰" />
        </el-form-item>
        <el-form-item label="开始平" prop="firstVal3rd">
          <el-input v-model="form.firstVal3rd" placeholder="请输入开始平" />
        </el-form-item>
        <el-form-item label="开始谷" prop="firstVal4th">
          <el-input v-model="form.firstVal4th" placeholder="请输入开始谷" />
        </el-form-item>
        <el-form-item label="最后尖" prop="lastVal1st">
          <el-input v-model="form.lastVal1st" placeholder="请输入最后尖" />
        </el-form-item>
        <el-form-item label="最后峰" prop="lastVal2nd">
          <el-input v-model="form.lastVal2nd" placeholder="请输入最后峰" />
        </el-form-item>
        <el-form-item label="最后平" prop="lastVal3rd">
          <el-input v-model="form.lastVal3rd" placeholder="请输入最后平" />
        </el-form-item>
        <el-form-item label="最后谷" prop="lastVal4th">
          <el-input v-model="form.lastVal4th" placeholder="请输入最后谷" />
        </el-form-item>
        <el-form-item label="净累积量" prop="cumulativeFlow">
          <el-input v-model="form.cumulativeFlow" placeholder="请输入净累积量" />
        </el-form-item>
        <el-form-item label="平均电池电压" prop="terminalVolAvg">
          <el-input v-model="form.terminalVolAvg" placeholder="请输入平均电池电压" />
        </el-form-item>
        <el-form-item label="起始抄表读数" prop="startReading">
          <el-input v-model="form.startReading" placeholder="请输入起始抄表读数" />
        </el-form-item>
        <el-form-item label="起始抄表时间" prop="startReadingTime">
          <el-date-picker clearable
            v-model="form.startReadingTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择起始抄表时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="终止抄表读数" prop="endReading">
          <el-input v-model="form.endReading" placeholder="请输入终止抄表读数" />
        </el-form-item>
        <el-form-item label="终止抄表时间" prop="endReadingTime">
          <el-date-picker clearable
            v-model="form.endReadingTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择终止抄表时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="用户平均用水量" prop="userAvg">
          <el-input v-model="form.userAvg" placeholder="请输入用户平均用水量" />
        </el-form-item>
        <el-form-item label="环比上一周期" prop="hb">
          <el-input v-model="form.hb" placeholder="请输入环比上一周期" />
        </el-form-item>
        <el-form-item label="冻结时间" prop="freezeTime">
          <el-input v-model="form.freezeTime" placeholder="请输入冻结时间" />
        </el-form-item>
        <el-form-item label="抄回状态(1：当天和前天都抄回数据,2：当天有数据抄回，前一天未抄回数据,3：当天未抄回数据。当天表示需要生成日用量的那天。)" prop="copyRate">
          <el-input v-model="form.copyRate" placeholder="请输入抄回状态(1：当天和前天都抄回数据,2：当天有数据抄回，前一天未抄回数据,3：当天未抄回数据。当天表示需要生成日用量的那天。)" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {getElectricityTerminalsFreezeXb, listElectricityTerminalsFreezeXb} from "@/api/datastatistics/electricity/electricityTerminalsFreezeXb";

  export default {
  name: "ElectricityTerminalsFreezeXb",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 电冻结数据（设备维度）表格数据
      electricityTerminalsFreezeXbList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        tenantId: null,
        supplierId: null,
        locationNb: null,
        terminalId: null,
        funId: null,
        ytId: null,
        firstVal: null,
        lastVal: null,
        minVal: null,
        maxVal: null,
        firstTime: null,
        lastTime: null,
        minTime: null,
        maxTime: null,
        dataValue: null,
        multiply: null,
        inVal: null,
        firstVal1st: null,
        firstVal2nd: null,
        firstVal3rd: null,
        firstVal4th: null,
        lastVal1st: null,
        lastVal2nd: null,
        lastVal3rd: null,
        lastVal4th: null,
        cumulativeFlow: null,
        terminalVolAvg: null,
        startReading: null,
        startReadingTime: null,
        endReading: null,
        endReadingTime: null,
        userAvg: null,
        hb: null,
        paramType: null,
        frozenType: null,
        freezeTime: null,
        copyRate: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        tenantId: [
          { required: true, message: "设备归属租户不能为空", trigger: "blur" }
        ],
        locationNb: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        funId: [
          { required: true, message: "功能ID号不能为空", trigger: "blur" }
        ],
        ytId: [
          { required: true, message: "反转ID号不能为空", trigger: "blur" }
        ],
        firstVal: [
          { required: true, message: "初始用电量不能为空", trigger: "blur" }
        ],
        lastVal: [
          { required: true, message: "最后用电量不能为空", trigger: "blur" }
        ],
        minVal: [
          { required: true, message: "最小值不能为空", trigger: "blur" }
        ],
        maxVal: [
          { required: true, message: "最大值不能为空", trigger: "blur" }
        ],
        firstTime: [
          { required: true, message: "初始时间不能为空", trigger: "blur" }
        ],
        lastTime: [
          { required: true, message: "最后更新时间不能为空", trigger: "blur" }
        ],
        minTime: [
          { required: true, message: "最小值发生时间不能为空", trigger: "blur" }
        ],
        maxTime: [
          { required: true, message: "最大值发生时间不能为空", trigger: "blur" }
        ],
        frozenType: [
          { required: true, message: "冻结类型，时：hour 日：day，月：month不能为空", trigger: "change" }
        ],
        freezeTime: [
          { required: true, message: "冻结时间不能为空", trigger: "blur" }
        ],
        createTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询电冻结数据（设备维度）列表 */
    getList() {
      this.loading = true;
      listElectricityTerminalsFreezeXb(this.queryParams).then(response => {
        this.electricityTerminalsFreezeXbList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        tenantId: null,
        supplierId: null,
        locationNb: null,
        terminalId: null,
        funId: null,
        ytId: null,
        firstVal: null,
        lastVal: null,
        minVal: null,
        maxVal: null,
        firstTime: null,
        lastTime: null,
        minTime: null,
        maxTime: null,
        dataValue: null,
        multiply: null,
        inVal: null,
        firstVal1st: null,
        firstVal2nd: null,
        firstVal3rd: null,
        firstVal4th: null,
        lastVal1st: null,
        lastVal2nd: null,
        lastVal3rd: null,
        lastVal4th: null,
        cumulativeFlow: null,
        terminalVolAvg: null,
        startReading: null,
        startReadingTime: null,
        endReading: null,
        endReadingTime: null,
        userAvg: null,
        hb: null,
        paramType: null,
        frozenType: null,
        freezeTime: null,
        createTime: null,
        copyRate: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加电冻结数据（设备维度）";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getElectricityTerminalsFreezeXb(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改电冻结数据（设备维度）";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateElectricityTerminalsFreezeXb(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addElectricityTerminalsFreezeXb(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除电冻结数据（设备维度）编号为"' + ids + '"的数据项？').then(function() {
        return delElectricityTerminalsFreezeXb(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('basedata/electricityTerminalsFreezeXb/export', {
        ...this.queryParams
      }, `electricityTerminalsFreezeXb_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
